#include <iostream>
#include "HashMapDy.h"
#include <cstring>

void Sort(std::string & s, int start, int end)
{
    if(start >= end)
        return;
    int left = start;
    int right = end;
    int temp = s[left];
    while(left < right)
    {
        while(left < right && s[right] > temp)
            right--;
        if(left < right)
            s[left++] = s[right];
        while(left < right && s[left] < temp)
            left++;
        if(left < right)
            s[right--] = s[left];
    }
    s[left] = temp;
    Sort(s, start, left - 1);
    Sort(s, right + 1, end);
}

int main()
{
    HashMap m(10);
#if 0
    // m.Insert("zhangsan",1);
    // m.Insert("lisi",2);
    // m.Insert("wangwu",6);

    // //重载[]后的写法
    // m["zhangsan"] = 2;
    // m["lisi"] = 5;
    // m["wangwu"] = 6;

    // std::cout<< m["lisi"]<<std::endl;
    // m["zhangsan"] = 5;

    std::string strs[] = {"zhang","wang","li","zhang","li","zhang"};
    for(int i = 0; i < sizeof(strs) / sizeof(std::string); i++)
    {
        m[strs[i]]++;   //起始是0，找到一个+1；！！
    }
    m.show();

#endif
#if 0    
    std::string strs[] = {"eat", "tea", "tan", "ate", "nat", "bat"};
    for(int i = 0; i < sizeof(strs) / sizeof(std::string); i++)
    {
        std::string temp = strs[i];
        Sort(temp, 0 , temp.size() - 1);
        m.Insert(temp, strs[i]);
    }
    m.showByKey();
#endif

    m["zhang"] = 1;
    m["li"] = 3;
    m["wang"] = 5;

    m.show();

    m.Remove("wang");
    m.show();
    return 0;
}